object frmjbzcodetool: Tfrmjbzcodetool
  Left = 0
  Top = 0
  Caption = #25605#25292#31449#32534#31243#24037#20855
  ClientHeight = 419
  ClientWidth = 838
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'Tahoma'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object Panel1: TPanel
    Left = 0
    Top = 0
    Width = 838
    Height = 76
    Align = alTop
    TabOrder = 0
    object Label1: TLabel
      Left = 56
      Top = 27
      Width = 60
      Height = 13
      Caption = #29983#20135#21378#23478#65306
    end
    object Label2: TLabel
      Left = 9
      Top = 54
      Width = 108
      Height = 13
      Caption = #29983#20135#21378#23478#20195#30721#27169#26495#65306
    end
    object ProjectName: TEdit
      Left = 112
      Top = 23
      Width = 161
      Height = 21
      TabOrder = 0
      Text = 'BS1200'
    end
    object btnexec: TButton
      Left = 296
      Top = 21
      Width = 145
      Height = 25
      Caption = #29983#25104#26032#37319#38598#25991#20214
      TabOrder = 1
      OnClick = btnexecClick
    end
    object cmbcodetype: TComboBox
      Left = 112
      Top = 50
      Width = 161
      Height = 21
      ItemIndex = 0
      TabOrder = 2
      Text = #40664#35748
      Items.Strings = (
        #40664#35748)
    end
    object Button1: TButton
      Left = 296
      Top = 47
      Width = 145
      Height = 25
      Caption = #19968#38190#26356#26032#21407#22987#20195#30721
      TabOrder = 3
      OnClick = btnexecClick
    end
  end
  object Panel2: TPanel
    Left = 0
    Top = 76
    Width = 838
    Height = 302
    Align = alClient
    TabOrder = 1
    object PageControl1: TPageControl
      Left = 1
      Top = 1
      Width = 836
      Height = 300
      ActivePage = tstask
      Align = alClient
      TabOrder = 0
      object tstask: TTabSheet
        Caption = 'initTask-'#25292#21512#20219#21153#34920
        object Panel4: TPanel
          Left = 0
          Top = 17
          Width = 828
          Height = 255
          Align = alClient
          TabOrder = 0
          object mmtask: TcxMemo
            Left = 1
            Top = 1
            Align = alClient
            Lines.Strings = (
              'function Tnewprojectname.InitTask: Boolean;'
              'var'
              '    TaskName: string;'
              '    TaskID, TRkid: string; //'#20219#21153'ID,'#37197#27604#26041#26696#20027#38190
              '    UseArea: string;   //'#24037#31243#37096#20301
              '    ToneName: string;   //'#37197#26041#21495
              ''
              '    Btime, Etime: string;  //'#24320#22987#26102#38388#65292#32467#26463#26102#38388
              '    Cube: double;      //'#20219#21153#26041#37327
              '    ActualCube: double; //'#23454#38469#26041#37327
              '    CardIdx: integer;    //'#32047#35745#36710#27425
              '    TrayIdx: integer;   //'#32047#35745#30424#25968
              ''
              '    TaskNameFields: string;'
              '    groupbyFields: string;'
              '    RetryTimes: Integer;'
              '    sSql: string;'
              '    qryvalue: TADOQuery;'
              'begin'
              '    Result := False;'
              '    TaskNameFields :='
              
                '        '#39'   '#23458#25143#21517#31216' + '#39#39'$'#39#39' + '#24037#31243#21517#31216' + '#39#39'$'#39#39' + '#26045#24037#21333#20301' + '#39#39'$'#39#39' + '#26045#24037#22320#28857' + ' +
                #39#39'$'#39#39' + '#39
              
                '       +'#39'   '#26045#24037#37324#31243' + '#39#39'$'#39#39' + '#24378#24230#31561#32423' + '#39#39'$'#39#39' + '#22349#33853#24230' + '#39#39'$'#39#39' + '#37197#26041#21495' + '#39#39 +
                '$'#39#39' AS TaskName '#39';'
              '    groupbyFields :='
              '        '#39'   '#23458#25143#21517#31216', '#24037#31243#21517#31216', '#26045#24037#21333#20301', '#26045#24037#22320#28857', '#26045#24037#37324#31243', '#24378#24230#31561#32423', '#22349#33853#24230', '#37197#26041#21495'  '#39';'
              '    qryvalue := TADOQuery.Create(nil);'
              '    qryvalue.Connection := DM.qMixtmp.Connection;'
              '    with DM do'
              '    begin'
              '       //'#26597#35810#33050#26412#65306#20219#21153#21333
              '        qMixtmp.Close;'
              '        qMixtmp.SQL.Text := '#39#39' +'
              '             '#39' SELECT MIN('#32534#21495') CODE,MIN('#26102#38388') AS BTime, '#39
              
                '            +'#39'        MAX(DATEADD( SECOND, '#25605#25292#26102#38388', '#26102#38388')) AS ETime, ' +
                #39
              '            +         TaskNameFields + '#39', '#39' +'
              '             '#39'        '#37197#26041#21495' AS ToneName, '#26045#24037#22320#28857' AS UseArea  '#39' +'
              '             '#39'  FROM  [dbo].['#29983#20135#35760#24405']  '#39
              '            +'#39' WHERE  '#32534#21495'>='#39' + FloatToStr(FOldMaxTrayID)'
              '            +'#39'        and '#32534#21495'<'#39' + FloatToStr(FNewMaxTrayID) +'
              
                '             '#39' GROUP  BY   '#39' + groupbyFields + '#39' order by code '#39 +
                ';'
              ''
              '        qMixtmp.Open;'
              '        qMixtmp.First;'
              '        while not qMixtmp.Eof do'
              '        begin'
              ''
              '            //'#26032#22686'Task'
              '            UseArea := qMixtmp.FieldByName('#39'UseArea'#39').AsString;'
              
                '            TaskName := qMixtmp.FieldByName('#39'TaskName'#39').AsString' +
                ';'
              
                '            ToneName := qMixtmp.FieldByName('#39'ToneName'#39').AsString' +
                ';'
              
                '            TaskID := string(StrToMD5Str(AnsiString( FSynconfigR' +
                'ec.Key'
              
                '                                                            + Ta' +
                'skName )));'
              '            RetryTimes := 0;'
              ''
              '            while True do'
              '            try'
              '                if not qTask.Locate('#39'TaskID'#39', TaskID, []) then'
              '                begin'
              '                    qTask.Append;'
              
                '                    qTask.FieldByName('#39'TaskID'#39').AsString := Task' +
                'ID;'
              '                end'
              '                else'
              '                begin'
              '                    qTask.Edit;'
              '                end;'
              ''
              
                '                qTask.FieldByName('#39'TaskName'#39').AsString := TaskNa' +
                'me;'
              
                '                qTask.FieldByName('#39'Proj_ID'#39').AsInteger := FSynco' +
                'nfigRec.Proj_id;'
              '                qTask['#39'MixNo'#39'] := FSynconfigRec.MixNo;'
              '                TRkid := '#39#39';'
              '                qTask.FieldByName('#39'TRkid'#39').AsString := TRkid;'
              
                '                qTask.FieldByName('#39'ToneName'#39').AsString := ToneNa' +
                'me;'
              
                '                qTask.FieldByName('#39'UseArea'#39').AsString := UseArea' +
                ';'
              '                qTask.FieldByName('#39'IsOver'#39').AsInteger := 0;'
              '                qTask.FieldByName('#39'SynIsDel'#39').AsInteger := 0;'
              
                '                qTask.FieldByName('#39'SynModifyTime'#39').AsDatetime :=' +
                ' Now;'
              ''
              '                //'#35745#31639#33539#30068
              '                Btime := qMixtmp.FieldByName('#39'Btime'#39').AsString;'
              '                Etime := qMixtmp.FieldByName('#39'Etime'#39').AsString;'
              '                sSql :='
              '                    '#39'SELECT  SUM('#26041#25968') AS Cube '#39
              '                   +'#39'  FROM  '#29983#20135#35760#24405' '#39
              
                '                   +'#39' WHERE  '#39' + TaskNameFields + '#39'='#39' + QuotedSt' +
                'r(TaskName);'
              '                qryvalue.Close;'
              '                qryvalue.SQL.Text := sSql;'
              '                qryvalue.Open;'
              
                '                ActualCube := qryvalue.FieldByName('#39'Cube'#39').AsFlo' +
                'at;'
              '                Cube := qryvalue.FieldByName('#39'Cube'#39').AsFloat;'
              '                sSql :='
              '                    '#39' SELECT  COUNT('#36710#25968')  '#39
              '                  + '#39'   FROM  '#29983#20135#35760#24405' '#39
              
                '                  + '#39'  WHERE  '#39' + TaskNameFields + '#39'='#39' + QuotedS' +
                'tr(TaskName)'
              '                  + '#39'  GROUP  BY '#36710#25968#39';'
              '                qryvalue.Close;'
              '                qryvalue.SQL.Text := sSql;'
              '                qryvalue.Open;'
              '                CardIdx := qryvalue.RecordCount;'
              '                sSql :='
              '                    '#39' SELECT  1 '#39
              '                   +'#39'   FROM  '#29983#20135#35760#24405' '#39
              
                '                   +'#39'  WHERE '#39'+ TaskNameFields + '#39'='#39' + QuotedStr' +
                '(TaskName);'
              ''
              '                qryvalue.Close;'
              '                qryvalue.SQL.Text := sSql;'
              '                qryvalue.Open;'
              '                TrayIdx := qryvalue.RecordCount;'
              ''
              '                qTask.FieldByName('#39'BTime'#39').AsString := Btime;'
              '                qTask.FieldByName('#39'ETime'#39').AsString := Etime;'
              '                qTask.FieldByName('#39'Cube'#39').AsFloat := Cube;'
              
                '                qTask.FieldByName('#39'ActualCube'#39').AsFloat := Actua' +
                'lCube;'
              
                '                qTask.FieldByName('#39'CardIdx'#39').AsInteger := CardId' +
                'x;'
              
                '                qTask.FieldByName('#39'TrayIdx'#39').AsInteger := TrayId' +
                'x;'
              ''
              '                qTask.Post;'
              '                Break;'
              '            except'
              '                on e: Exception do'
              '                begin'
              '                    qryvalue.Free;'
              '                    ShowMessage(e.Message);'
              '                    Inc(RetryTimes);'
              
                '                    WriteRealLog(FTodayLog, Format('#39#31532'%d'#27425' qTask.p' +
                'ost %s'#39','
              
                '                                                      [RetryTime' +
                's, e.Message]));'
              '                    if RetryTimes > 2 then'
              '                        Exit;'
              '                    qTask.Close;'
              '                    qTask.open;'
              '                    if qTask.IsEmpty then'
              '                        Break;'
              '                end;'
              '            end;'
              '            qMixtmp.next;'
              '        end;'
              '    end;'
              ''
              '    qryvalue.Free;'
              '    Result := True;'
              'end;')
            TabOrder = 0
            Height = 253
            Width = 826
          end
        end
        object Panel5: TPanel
          Left = 0
          Top = 0
          Width = 828
          Height = 17
          Align = alTop
          TabOrder = 1
        end
      end
      object tsqueue: TTabSheet
        Caption = 'InitQueue-'#27966#36710#21333
        ImageIndex = 1
        object Panel6: TPanel
          Left = 0
          Top = 0
          Width = 828
          Height = 17
          Align = alTop
          TabOrder = 0
        end
        object Panel7: TPanel
          Left = 0
          Top = 17
          Width = 828
          Height = 255
          Align = alClient
          TabOrder = 1
          object mmqueue: TcxMemo
            Left = 1
            Top = 1
            Align = alClient
            Lines.Strings = (
              ''
              'function Tnewprojectname.InitQueue: Boolean;'
              'var'
              '    Queuekid, TRkid, TaskID, sSql: string;'
              '    RetryTimes: Integer;'
              '    qryvalue: TADOQuery;'
              '    TaskName: string;'
              '    UseArea: string;   //'#24037#31243#37096#20301
              '    ToneName: string;   //'#37197#26041#21495
              '    CarNumber: string;  //'#36710#21495
              ''
              '    Driver: string; //'#21496#26426
              '    Oper: string;  //'#25805#20316#21592
              '    conAddress: string; //'#27700#27877#20135#22320
              ''
              '    Btime, Etime: string;  //'#24320#22987#26102#38388#65292#32467#26463#26102#38388
              '    Cube: Double;      //'#20219#21153#26041#37327
              '    ActualCube: Double; //'#23454#38469#26041#37327
              ''
              '    CardIdx: Integer;    //'#20219#21153#36710#27425#39034#24207
              '    TrayCube: Double;   //'#27599#30424#26041#37327
              '    TrayCount: Integer; //'#35745#21010#25968
              '    TrayIdx: Integer;   //'#23436#25104#30424#25968
              ''
              '    TaskNameFields: string;'
              '    groupbyFields: string;'
              'begin'
              '    Result := False;'
              '    TaskNameFields :='
              
                '        '#39'   '#23458#25143#21517#31216' + '#39#39'$'#39#39' + '#24037#31243#21517#31216' + '#39#39'$'#39#39' + '#26045#24037#21333#20301' + '#39#39'$'#39#39' + '#26045#24037#22320#28857' + ' +
                #39#39'$'#39#39' + '#39
              
                '       +'#39'   '#26045#24037#37324#31243' + '#39#39'$'#39#39' + '#24378#24230#31561#32423' + '#39#39'$'#39#39' + '#22349#33853#24230' + '#39#39'$'#39#39' + '#37197#26041#21495' + '#39#39 +
                '$'#39#39' AS TaskName '#39';'
              '    groupbyFields :='
              '        '#39'   '#23458#25143#21517#31216', '#24037#31243#21517#31216', '#26045#24037#21333#20301', '#26045#24037#22320#28857', '#26045#24037#37324#31243', '#24378#24230#31561#32423', '#22349#33853#24230', '#37197#26041#21495'  '#39';'
              '    qryvalue := TADOQuery.Create(nil);'
              '    qryvalue.Connection := DM.qMixtmp.Connection;'
              '    with DM do'
              '    begin'
              '        qMixtmp.Close;'
              '        qMixtmp.SQL.Text :='
              '            '#39' SELECT  MIN('#32534#21495') AS CODE,MIN('#26102#38388') AS BTime,'#39
              
                '           +'#39'         MAX(DATEADD( SECOND, '#25605#25292#26102#38388', '#26102#38388')) AS ETime, ' +
                #39
              
                '           +          TaskNameFields + '#39', '#36710#25968' AS  CarNumber, '#36710#29260#21495#30721 +
                ', '#39
              '           +'#39'         '#37197#26041#21495' AS ToneName, '#26045#24037#22320#28857' AS UseArea  '#39
              '           +'#39'  FROM   [dbo].['#29983#20135#35760#24405']  '#39
              '           +'#39' WHERE   '#32534#21495'>='#39' + FloatToStr(FOldMaxTrayID)'
              '           +'#39'         AND '#32534#21495'<'#39' + FloatToStr(FNewMaxTrayID)'
              '           +'#39' GROUP   BY   '#39' + groupbyFields'
              '           +'#39' ORDER   BY CODE '#39';'
              '        try'
              '            qMixtmp.Open;'
              '        except'
              '            on e: Exception do'
              '            begin'
              '                ShowMessage(e.Message);'
              '            end;'
              ''
              '        end;'
              ''
              '        qMixtmp.First;'
              '        while not qMixtmp.Eof do'
              '        begin'
              '            //'#26032#22686#27966#36710#21333
              
                '            TaskName :=  qMixtmp.FieldByName('#39'TaskName'#39').AsStrin' +
                'g;'
              '            UseArea :=  qMixtmp.FieldByName('#39'UseArea'#39').AsString;'
              
                '            ToneName :=  qMixtmp.FieldByName('#39'ToneName'#39').AsStrin' +
                'g;'
              
                '            CarNumber :=  qMixtmp.FieldByName('#39'CarNumber'#39').AsStr' +
                'ing;'
              
                '            Queuekid := string(StrToMD5Str(AnsiString(FSynconfig' +
                'Rec.Key'
              
                '                                                    + TaskName+C' +
                'arNumber )));'
              ''
              '            RetryTimes := 0;'
              '            while True do'
              '            try'
              '                if not qQueue.Locate('#39'Kid'#39', Queuekid, []) then'
              '                begin'
              '                    qQueue.Append;'
              '                end'
              '                else'
              '                begin'
              '                    qQueue.Edit;'
              '                end;'
              ''
              '                qQueue.FieldByName('#39'Kid'#39').AsString := Queuekid;'
              
                '                qQueue.FieldByName('#39'Proj_ID'#39').Value := FSynconfi' +
                'gRec.Proj_id;'
              '                TaskID := FSynconfigRec.Key + TaskName;'
              
                '                TaskID := string(StrToMD5Str(AnsiString(TaskID))' +
                ');'
              '                qQueue.FieldByName('#39'Taskid'#39').AsString := TaskID;'
              
                '                qQueue.FieldByName('#39'TaskName'#39').AsString := TaskN' +
                'ame;'
              
                '                qQueue.FieldByName('#39'UseArea'#39').AsString := UseAre' +
                'a;'
              '                TRkid := '#39#39';'
              '                qQueue.FieldByName('#39'TRkid'#39').AsString := TRkid;'
              
                '                qQueue.FieldByName('#39'ToneName'#39').AsString := ToneN' +
                'ame;'
              '                qQueue.FieldByName('#39'CarNumber'#39').AsString :='
              
                '                                        qMixtmp.FieldByName('#39#36710#29260#21495 +
                #30721#39').AsString;'
              
                '                qQueue.FieldByName('#39'Selected'#39').AsBoolean := Fals' +
                'e;'
              '                BTime :=qMixtmp.FieldByName('#39'BTime'#39').AsString;'
              '                ETime :=qMixtmp.FieldByName('#39'ETime'#39').AsString;'
              '                qQueue.FieldByName('#39'IsOver'#39').AsInteger := 0;'
              '                qQueue.FieldByName('#39'SynIsDel'#39').AsInteger := 0;'
              
                '                qQueue.FieldByName('#39'SynModifyTime'#39').AsDatetime :' +
                '= Now;'
              ''
              ''
              '                //'#35745#31639#20854#20182
              
                '                sSql :='#39'SELECT  '#25805#20316#20154#21592' AS conAddress, '#26045#24037#22320#28857' AS Oper' +
                ', '#39550#39542#20154#21592' AS Driver '#39
              '                      +'#39'  FROM  '#29983#20135#35760#24405' '#39
              
                '                      +'#39'  WHERE '#39' + TaskNameFields + '#39'='#39' + Quote' +
                'dstr(TaskName)'
              '                      +'#39'        AND '#36710#25968'='#39' + QuotedStr(CarNumber);'
              '                qryvalue.Close;'
              '                qryvalue.SQL.Text := sSql;'
              '                qryvalue.Open;'
              
                '                conAddress := qryvalue.FieldByName('#39'conAddress'#39')' +
                '.AsString;'
              '                Oper := qryvalue.FieldByName('#39'Oper'#39').AsString;'
              
                '                Driver := qryvalue.FieldByName('#39'Driver'#39').AsStrin' +
                'g;'
              ''
              '                sSql :='#39'vSELECT  SUM('#26041#25968') AS CUBE '#39
              '                      +'#39'   FROM  '#29983#20135#35760#24405' '#39
              
                '                      +'#39'  WHERE  '#39' + TaskNameFields + '#39'='#39' + Quot' +
                'edstr(TaskName)'
              
                '                      +'#39'         AND '#36710#25968'='#39' + QuotedStr(CarNumber)' +
                ';'
              '                qryvalue.Close;'
              '                qryvalue.SQL.Text := sSql;'
              '                qryvalue.Open;'
              '                Cube := qryvalue.FieldByName('#39'cube'#39').AsFloat;'
              
                '                ActualCube := qryvalue.FieldByName('#39'cube'#39').AsFlo' +
                'at;'
              
                '                sSql :='#39'SELECT  '#36710#25968', ROW_NUMBER() OVER(PARTITION ' +
                'BY  1 ORDER BY '#36710#25968') AS CardIdx '#39
              '                      +'#39'  FROM  '#29983#20135#35760#24405' '#39
              
                '                      +'#39' WHERE  '#39' + TaskNameFields + '#39'='#39' + Quote' +
                'dstr(TaskName)'
              '                      +'#39' GROUP  BY '#36710#25968' ORDER BY '#36710#25968#39';'
              ''
              '                qryvalue.Close;'
              '                qryvalue.SQL.Text := sSql;'
              '                qryvalue.Open;'
              '                with qryvalue do'
              '                begin'
              '                   CardIdx := 1;'
              '                   First;'
              '                   while not Eof do'
              '                   begin'
              
                '                     if CarNumber = FieldByName('#39#36710#25968#39').AsString t' +
                'hen'
              '                     begin'
              
                '                       CardIdx :=  FieldByName('#39'CardIdx'#39').AsInte' +
                'ger;  //'#20219#21153#36710#27425#39034#24207
              '                       Break;'
              '                     end;'
              '                     Next;'
              '                   end;'
              '                end;'
              ''
              '                sSql :='#39' SELECT  Max('#30424#25968') as TrayCount '#39
              '                      +'#39'   FROM  '#29983#20135#35760#24405' '#39
              
                '                      +'#39'  WHERE  '#39' + TaskNameFields + '#39'='#39' + Quot' +
                'edstr(TaskName)'
              
                '                      +'#39'         AND '#36710#25968'='#39' + QuotedStr(CarNumber)' +
                ';'
              '                qryvalue.Close;'
              '                qryvalue.SQL.Text := sSql;'
              '                qryvalue.Open;'
              '                TrayCube := 0;'
              
                '                TrayCount := qryvalue.FieldByName('#39'TrayCount'#39').A' +
                'sInteger;'
              
                '                TrayIdx := qryvalue.FieldByName('#39'TrayCount'#39').AsI' +
                'nteger;'
              '                if TrayCount<>0 then'
              '                   TrayCube := Cube /  TrayCount;'
              ''
              
                '                qQueue.FieldByName('#39'conAddress'#39').AsString := con' +
                'Address;'
              '                qQueue.FieldByName('#39'Operator'#39').AsString := Oper;'
              '                qQueue.FieldByName('#39'Cube'#39').AsFloat := Cube;'
              
                '                qQueue.FieldByName('#39'ActualCube'#39').AsFloat := Actu' +
                'alCube;'
              
                '                qQueue.FieldByName('#39'CardIdx'#39').AsInteger := CardI' +
                'dx;'
              
                '                qQueue.FieldByName('#39'SortSeq'#39').asInteger := CardI' +
                'dx;'
              
                '                qQueue.FieldByName('#39'QueueId'#39').AsInteger := CardI' +
                'dx;'
              
                '                qQueue.FieldByName('#39'TrayCube'#39').AsFloat := TrayCu' +
                'be;'
              
                '                qQueue.FieldByName('#39'TrayCount'#39').AsFloat :=  Tray' +
                'Count;'
              
                '                qQueue.FieldByName('#39'TrayIdx'#39').asInteger := TrayI' +
                'dx;'
              '                qQueue.Post;'
              '                Break;'
              '            except'
              '                on e: Exception do'
              '                begin'
              '                    qryvalue.Free;'
              '                    Inc(RetryTimes);'
              
                '                    WriteRealLog(FTodayLog, Format('#39#31532'%d'#27425' qQueue.' +
                'post %s'#39','
              
                '                                                         [RetryT' +
                'imes, e.Message]));'
              '                    if RetryTimes > 2 then'
              '                        Exit;'
              '                    qQueue.Close;'
              '                    qQueue.open;'
              '                    if qQueue.IsEmpty then'
              '                        Break;'
              '                end;'
              '            end;'
              ''
              
                '            if not InitQueueDetail(TaskNameFields,TaskName, CarN' +
                'umber)  //'#26126#32454
              '                then'
              '                Exit;'
              ''
              '            qMixtmp.next;'
              '        end;'
              '    end;'
              '    qryvalue.Free;'
              '    Result := True;'
              'end;')
            TabOrder = 0
            Height = 253
            Width = 826
          end
        end
      end
      object tsqueuedetail: TTabSheet
        Caption = 'initqueuedetail-'#27599#36710#30340#26126#32454
        ImageIndex = 2
        object Panel8: TPanel
          Left = 0
          Top = 0
          Width = 828
          Height = 17
          Align = alTop
          TabOrder = 0
        end
        object Panel9: TPanel
          Left = 0
          Top = 17
          Width = 828
          Height = 255
          Align = alClient
          TabOrder = 1
          object mmqueuedetail: TcxMemo
            Left = 1
            Top = 1
            Align = alClient
            Lines.Strings = (
              ''
              
                'function Tnewprojectname.InitQueueDetail(TaskNameFields,TaskName' +
                ', CarNumber:'
              '    string): Boolean;'
              'var'
              '    nIndex: Integer;'
              '    QueueKid: string;'
              '    RetryTimes: Integer;'
              '    i: Integer;'
              '    sMaterial: string;'
              '    dDesign, dActual: Double;'
              ''
              'begin'
              '    Result := False;'
              '    RetryTimes := 0;'
              '    with DM do'
              '    begin'
              '        qDosage.Close;'
              '        qDosage.SQL.Text :='
              '                       '#39' SELECT   * '#39
              '                      +'#39'   FROM  '#29983#20135#35760#24405' '#39
              
                '                      +'#39'  WHERE  '#39' + TaskNameFields + '#39'='#39' + Quot' +
                'edstr(TaskName)'
              
                '                      +'#39'         AND '#36710#25968'='#39' + QuotedStr(CarNumber)' +
                ';'
              
                '        QueueKid := string(StrToMD5Str(AnsiString(FSynconfigRec.' +
                'Key +'
              '            TaskName+CarNumber)));'
              ''
              '        qStorage.First;'
              '        while not qStorage.Eof do'
              '        begin'
              '            nIndex := qStorage.FieldByName('#39'LineID'#39').AsInteger;'
              
                '            sMaterial := qStorage.FieldByName('#39'Material'#39').AsStri' +
                'ng;'
              '            dActual := 0;'
              '            dDesign := 0;'
              '            for i := 0 to FLinkLst.Count - 1 do'
              '            begin'
              '                if Storage2WP2(FLinkLst.Names[i]) = nIndex then'
              '                begin'
              '                    qDosage.First;'
              '                    while not qDosage.eof do'
              '                    begin'
              
                '                        if qDosage.Fields.FindField(FLinkLst.Nam' +
                'es[i]+'#39#28040#32791#37327#39')<> nil then'
              '                        begin'
              '                            dActual := dActual'
              
                '                                     + qDosage.FieldByName(FLink' +
                'Lst.Names[i]+'#39#28040#32791#37327#39').AsFloat;'
              '                        end;'
              
                '                        if qDosage.Fields.FindField(FLinkLst.Nam' +
                'es[i]+ '#39#37197#26041#39') <> nil then'
              '                        begin'
              '                            dDesign := dDesign'
              
                '                                     + qDosage.FieldByName(FLink' +
                'Lst.Names[i] + '#39#37197#26041#39').AsFloat;'
              '                        end;'
              '                        qDosage.Next;'
              '                    end;'
              '                end;'
              '            end;'
              ''
              '            while True do'
              '            try'
              '                if qQueueDetailed.Locate('#39'QueueKid;Material'#39','
              '                    VarArrayOf([QueueKid, sMaterial]), []) then'
              '                    qQueueDetailed.Edit'
              '                else'
              '                begin'
              '                    qQueueDetailed.Append;'
              '                    qQueueDetailed['#39'QueueKid'#39'] := QueueKid;'
              '                    qQueueDetailed['#39'LineID'#39'] := nIndex;'
              '                    qQueueDetailed['#39'Material'#39'] := sMaterial;'
              '                    qQueueDetailed['#39'WaterContent'#39'] := -1;'
              '                    qQueueDetailed['#39'Design'#39'] := 0;'
              '                    qQueueDetailed['#39'Actual'#39'] := 0;'
              '                end;'
              '                qQueueDetailed['#39'Material'#39'] := sMaterial;'
              '                qQueueDetailed['#39'Design'#39'] := dDesign;'
              '                qQueueDetailed['#39'Actual'#39'] := dActual;'
              ''
              '                qQueueDetailed['#39'ErrorAdd'#39'] := 0;'
              '                qQueueDetailed['#39'WaterContent'#39'] := -1;'
              '                qQueueDetailed['#39'SynModifyTime'#39'] := Now;'
              '                qQueueDetailed['#39'SynIsDel'#39'] := 0;'
              '                qQueueDetailed.Post;'
              '                break;'
              '            except'
              '                on e: Exception do'
              '                begin'
              '                    Inc(RetryTimes);'
              
                '                    WriteRealLog(FTodayLog, Format('#39#31532'%d'#27425' qQueueD' +
                'etailed.post %s'#39','
              
                '                                                    [RetryTimes,' +
                ' e.Message]) );'
              '                    if RetryTimes > 2 then'
              '                        Exit;'
              '                    qQueueDetailed.Close;'
              '                    qQueueDetailed.open;'
              '                    if qQueueDetailed.IsEmpty then'
              '                        Break;'
              '                end;'
              '            end;'
              ''
              '            qStorage.Next;'
              '        end;'
              '    end;'
              ''
              '    Result := True;'
              'end;')
            TabOrder = 0
            Height = 253
            Width = 826
          end
        end
      end
      object tsTray: TTabSheet
        Caption = 'initTray-'#27599#30424#20449#24687
        ImageIndex = 3
        object Panel10: TPanel
          Left = 0
          Top = 0
          Width = 828
          Height = 17
          Align = alTop
          TabOrder = 0
        end
        object Panel11: TPanel
          Left = 0
          Top = 17
          Width = 828
          Height = 255
          Align = alClient
          TabOrder = 1
          object mmtray: TcxMemo
            Left = 1
            Top = 1
            Align = alClient
            Lines.Strings = (
              ''
              'function Tnewprojectname.InitTray: Boolean;'
              'var'
              '    TaskName: string;'
              '    CarNumber:string; //'#36710#25968
              '    TaskID,TrayID,TrayIDWithKey: string; //'#20219#21153'ID,'#37197#27604#26041#26696#20027#38190
              '    Btime, Etime: string;  //'#24320#22987#26102#38388#65292#32467#26463#26102#38388
              '    Cube: double;      //'#27599#30424#26041#37327
              '    CardTrayIdx:integer;  // '#32047#35745#30424#25968' ,'#25353#36710#35745#31639
              '    TrayIdx: integer;   //'#32047#35745#30424#27425','#25353#20219#21153#35745#31639
              '    CardIdx: integer;    //'#32047#35745#36710#27425
              '    UseTime: double;  //'#25605#25292#26102#38271
              '    CarNumberinfo:string; // '#36710#29260#21495
              '    TaskNameFields: string;'
              '    RetryTimes: Integer;'
              '    qryvalue: TADOQuery;'
              'begin'
              '    Result := False;'
              '    TaskName := '#39#39';'
              '    CarNumberinfo := '#39#39';'
              '    CarNumber := '#39#39';'
              '    Btime :='#39'1900-01-01'#39';'
              '    Etime :='#39'1900-01-01'#39';'
              '    TaskNameFields :='
              
                '        '#39'   '#23458#25143#21517#31216' + '#39#39'$'#39#39' + '#24037#31243#21517#31216' + '#39#39'$'#39#39' + '#26045#24037#21333#20301' + '#39#39'$'#39#39' + '#26045#24037#22320#28857' + ' +
                #39#39'$'#39#39' + '#39
              
                '       +'#39'   '#26045#24037#37324#31243' + '#39#39'$'#39#39' + '#24378#24230#31561#32423' + '#39#39'$'#39#39' + '#22349#33853#24230' + '#39#39'$'#39#39' + '#37197#26041#21495' + '#39#39 +
                '$'#39#39' AS TaskName '#39';'
              ''
              '    qryvalue := TADOQuery.Create(nil);'
              '    qryvalue.Connection := DM.qStorage.Connection;'
              ''
              '    DM.qMixtmp.Close;'
              '    DM.qMixtmp.SQL.Text := '#39#39' +'
              
                '            '#39' SELECT '#32534#21495' AS CODE,'#26102#38388' AS BTime,MAX(DATEADD( SECOND,' +
                ' '#25605#25292#26102#38388', '#26102#38388')) AS ETime, '#39
              
                '          +          TaskNameFields + '#39', '#30424#25968' AS CardTrayIdx,'#36710#25968' AS' +
                ' CarNumber, '#39
              '          + '#39'        '#36710#29260#21495#30721' AS  CarNumerinfo,'#39
              
                '          + '#39'        '#25605#25292#26102#38388' AS UseTime, '#26041#25968' AS Cube, CAST (RIGHT('#36710#25968 +
                ',3) AS INT) AS CardIdx  '#39' +'
              '            '#39'  FROM   [dbo].['#29983#20135#35760#24405']  '#39
              '          + '#39' WHERE  '#32534#21495'>='#39' + FloatToStr(FOldMaxTrayID)'
              '          + '#39'        AND '#32534#21495'<'#39' + FloatToStr(FNewMaxTrayID)'
              '          + '#39' ORDERs BY CODE '#39';;'
              '    DM.qMixtmp.Open;'
              '    DM.qMixtmp.First;'
              '    while not DM.qMixtmp.Eof do'
              '    begin'
              '    //'#20445#23384#30424#25968#25454
              '        with DM.qTray do'
              '        begin'
              '            TrayID := DM.qMixtmp.FieldByName('#39'code'#39').AsString;'
              
                '            TrayIDWithKey := string(StrToMD5Str(AnsiString( FSyn' +
                'configRec.Key'
              
                '                                                          + Tray' +
                'ID )));'
              
                '            TaskName :=  DM.qMixtmp.FieldByName('#39'TaskName'#39').AsSt' +
                'ring;'
              
                '            CarNumber :=  DM.qMixtmp.FieldByName('#39'CarNumber'#39').As' +
                'String;'
              '            RetryTimes := 0;'
              '            while True do'
              '            try'
              '                if Locate('#39'TrayID'#39', TrayIDWithKey, []) then'
              '                    Edit'
              '                else'
              '                begin'
              '                    Append;'
              
                '                    fieldByName('#39'TrayID'#39').AsString := TrayIDWith' +
                'Key;'
              '                end;'
              
                '                TaskId := string(StrToMD5Str(AnsiString(  FSynco' +
                'nfigRec.Key'
              
                '                                                        + TaskNa' +
                'me )));'
              '                FieldByName('#39'TaskID'#39').AsString := TaskId; //'#20219#21153'ID'
              
                '                FieldByName('#39'QueueKid'#39').AsString := string(StrTo' +
                'MD5Str    //'#38431#21015'kid'
              
                '                          (AnsiString( FSynconfigRec.Key + TaskN' +
                'ame+CarNumber )));'
              ''
              
                '                CarNumberinfo :=  DM.qMixtmp.FieldByName('#39'CarNum' +
                'erinfo'#39').AsString;'
              
                '                Btime :=  DM.qMixtmp.FieldByName('#39'Btime'#39').AsStri' +
                'ng;'
              
                '                Etime := DM.qMixtmp.FieldByName('#39'Etime'#39').AsStrin' +
                'g;'
              
                '                UseTime :=  DM.qMixtmp.FieldByName('#39'UseTime'#39').As' +
                'Float;'
              
                '                TrayIdx := DM.qMixtmp.FieldByName('#39'TrayIdx'#39').AsI' +
                'nteger;'
              
                '                CardTrayIdx := DM.qMixtmp.FieldByName('#39'CardTrayI' +
                'dx'#39').AsInteger;'
              
                '                CardIdx := DM.qMixtmp.FieldByName('#39'CardIdx'#39').AsI' +
                'nteger;'
              '                Cube :=  DM.qMixtmp.FieldByName('#39'Cube'#39').AsFloat;'
              ''
              
                '                FieldByName('#39'CarNumber'#39').AsString := CarNumberin' +
                'fo;'
              '                FieldByName('#39'TrayIdx'#39').AsInteger := TrayIdx;'
              
                '                FieldByName('#39'CardTrayIdx'#39').AsInteger := CardTray' +
                'Idx;'
              '                FieldByName('#39'CardIdx'#39').AsInteger := CardIdx;'
              '                FieldByName('#39'Btime'#39').AsString := Btime;'
              '                FieldByName('#39'Etime'#39').AsString := Etime;'
              '                fieldByName('#39'UseTime'#39').AsFloat := UseTime;'
              '                FieldByName('#39'Cube'#39').AsFloat := Cube;'
              ''
              '                FieldByName('#39'Auto'#39').AsInteger := 1; //'#26159#21542#20026#33258#21160
              '                FieldByName('#39'Offset'#39').AsInteger := 0;'
              
                '                FieldByName('#39'TLevel'#39').AsInteger := 0;  //'#25605#25292#26102#38388#35823#24046#31561 +
                #32423
              '                FieldByName('#39'SynIsDel'#39').AsInteger := 0;'
              '                FieldByName('#39'SynModifyTime'#39').AsDatetime := now;'
              
                '                FieldByName('#39'ServTime'#39').AsDateTime := IncSecond ' +
                '('
              
                '                                     DM.qMixtmp.FieldByName('#39'Eti' +
                'me'#39').AsFloat,'
              
                '                                     FSynconfigRec.SecondDiff  )' +
                ';'
              ''
              '                Post;'
              '                break;'
              '            except'
              '                on e: Exception do'
              '                begin'
              '                    inc(RetryTimes);'
              
                '                    WriteRealLog(FTodayLog, Format('#39#31532'%d'#27425' qTray.p' +
                'ost %s'#39','
              
                '                                                  [RetryTimes, e' +
                '.Message]));'
              '                    if RetryTimes > 2 then'
              '                        exit;'
              '                    DM.qTray.Close;'
              '                    DM.qTray.open;'
              '                    if DM.qTray.IsEmpty then'
              '                        break;'
              '                end;'
              '            end;'
              '        end;'
              ''
              '        if not InitTrayDetail(TaskID,Etime) then'
              '            exit;'
              '        DM.qMixtmp.next;'
              '    end;'
              '    qryvalue.Free;'
              '    Result := True;'
              'end;')
            TabOrder = 0
            Height = 253
            Width = 826
          end
        end
      end
      object tsTraydetail: TTabSheet
        Caption = 'initTraydetail-'#30424#26126#32454
        ImageIndex = 4
        object Panel12: TPanel
          Left = 0
          Top = 0
          Width = 828
          Height = 17
          Align = alTop
          TabOrder = 0
        end
        object Panel13: TPanel
          Left = 0
          Top = 17
          Width = 828
          Height = 255
          Align = alClient
          TabOrder = 1
          object mmtraydetail: TcxMemo
            Left = 1
            Top = 1
            Align = alClient
            Lines.Strings = (
              ''
              
                'function Tnewprojectname.InitTrayDetail(TaskID, Etime: string): ' +
                'Boolean;'
              'var'
              '    nIndex, RetryTimes: Integer;'
              '    TrayIDWithKey: string;'
              '    secdiff: Integer;'
              '    i: Integer;'
              '    sMaterial: string;'
              '    dDesign, dActual: Double;'
              'begin'
              '    Result := False;'
              '    RetryTimes := 0;'
              '    secdiff := FSynconfigRec.SecondDiff; //'#26412#22320#21644#26381#21153#22120#26102#38388#24046
              '    with DM do'
              '    begin'
              '       //'#26597#35810#30424#26126#32454
              '        qDosage.Close;'
              '        qDosage.SQL.Text :='
              '                       '#39' SELECT   * '#39
              '                      +'#39'   FROM  '#29983#20135#35760#24405' '#39
              '                      +'#39'  WHERE  '#32534#21495'='#39'+TaskID;'
              ''
              '        qDosage.Open;'
              
                '        TrayIDWithKey := string(StrToMD5Str(AnsiString(   FSynco' +
                'nfigRec.Key'
              
                '                                                        + TaskID' +
                ' )));'
              ''
              '        qStorage.First;'
              '        while not qStorage.Eof do'
              '        begin'
              '            nIndex := qStorage.FieldByName('#39'LineID'#39').AsInteger;'
              
                '            sMaterial := qStorage.FieldByName('#39'Material'#39').AsStri' +
                'ng;'
              '            dActual := 0;'
              '            dDesign := 0;'
              '            for i := 0 to FLinkLst.Count - 1 do'
              '            begin'
              '                if Storage2WP2(FLinkLst.Names[i]) = nIndex then'
              '                begin'
              '                    qDosage.First;'
              '                    while not qDosage.eof do'
              '                    begin'
              
                '                        if qDosage.Fields.FindField(FLinkLst.Nam' +
                'es[i] + '#39#28040#32791#37327#39')<> nil then'
              '                        begin'
              '                            dActual := dActual +'
              
                '                                       qDosage.FieldByName(FLink' +
                'Lst.Names[i] + '#39#28040#32791#37327#39').AsFloat;'
              '                        end;'
              
                '                        if qDosage.Fields.FindField(FLinkLst.Nam' +
                'es[i] + '#39#37197#26041#39') <> nil then'
              '                        begin'
              '                            dDesign := dDesign +'
              
                '                                       qDosage.FieldByName(FLink' +
                'Lst.Names[i] + '#39#37197#26041#39').AsFloat;'
              '                        end;'
              '                        qDosage.Next;'
              '                    end;'
              '                end;'
              '            end;'
              ''
              '            while True do'
              '            try'
              
                '                if qTrayActual.Locate('#39'TrayID;Material'#39', VarArra' +
                'yOf([TrayIDWithKey,'
              '                    sMaterial]), []) then'
              '                begin'
              '                    qTrayActual.Edit;'
              '                end'
              '                else'
              '                begin'
              '                    qTrayActual.Append;'
              
                '                    qTrayActual['#39'TrayID'#39'] := TrayIDWithKey; //'#30424'I' +
                'D'
              
                '                    qTrayActual['#39'Material'#39'] := sMaterial; //'#21407#26448#26009#21517 +
                #31216
              '                    qTrayActual['#39'LineID'#39'] := nIndex; //'#26009#20179#20256#24863#22120'ID'
              '                    qTrayActual['#39'DryDesign'#39'] := 0;   //'#19981#21547#27700#35774#35745#29992#37327
              '                    qTrayActual['#39'DryActual'#39'] := 0;  //'#21547#27700#29575
              '                    qTrayActual['#39'Offset'#39'] := 0;'
              '                    qTrayActual['#39'WaterContent'#39'] := -1;'
              '                end;'
              '                qTrayActual['#39'Design'#39'] := dDesign;'
              '                qTrayActual['#39'Actual'#39'] := dActual;'
              '                qTrayActual['#39'SynModifyTime'#39'] := now;'
              '                qTrayActual['#39'SynIsDel'#39'] := 0;'
              '                qTrayActual['#39'WaterContent'#39'] := -1;'
              
                '                qTrayActual.FieldByName('#39'DtTime'#39').AsString := Et' +
                'ime;'
              '                    //'#25171#26009#26102#38388
              
                '                qTrayActual.FieldByName('#39'ServTime'#39').AsDateTime :' +
                '='
              '                    IncSecond(StrToDateTime(Etime), secdiff);'
              '                    //'#25171#26009#26102#20505#65292#26381#21153#22120#26102#38388
              '                qTrayActual.Post;'
              '                break;'
              '            except'
              '                on e: Exception do'
              '                begin'
              '                    inc(RetryTimes);'
              
                '                    WriteRealLog(FTodayLog, Format('#39#31532'%d'#27425' qTrayAc' +
                'tual.post %s'#39','
              '                        [RetryTimes, e.Message]));'
              '                    if RetryTimes > 2 then'
              '                        exit;'
              '                    qTrayActual.Close;'
              '                    qTrayActual.open;'
              '                    if qTrayActual.IsEmpty then'
              '                        break;'
              '                end;'
              '            end;'
              ''
              '            qStorage.Next;'
              '        end;'
              ''
              '    end;'
              ''
              '    Result := True;'
              'end;')
            TabOrder = 0
            Height = 253
            Width = 826
          end
        end
      end
      object tableinfo: TTabSheet
        Caption = #34920#23383#27573#35828#26126
        ImageIndex = 5
        object Panel14: TPanel
          Left = 0
          Top = 0
          Width = 828
          Height = 272
          Align = alClient
          TabOrder = 0
          object cxMemo1: TcxMemo
            Left = 1
            Top = 1
            Align = alClient
            Lines.Strings = (
              #20219#21153':'
              '    ToneName //'#37197#26041#21517#31216
              '    TaskName  //'#20219#21153#21517#31216
              '    UseArea'#9'VARCHAR(320)'#9#24037#31243#37096#20301
              '    Cube  '#9'DECIMAL(8,3)'#9#20219#21153#26041#37327
              '    Btime'#9'  DATETIME'#9'    '#24320#22987#26102#38388
              '    Etime'#9'  DATETIME'#9'    '#32467#26463#26102#38388
              '    CardIdx'#9'INT'#9'          '#32047#35745#36710#27425
              '    TrayIdx'#9'INT'#9'              '#32047#35745#30424#27425
              '    ActualCube'#9'DECIMAL(8,3)'#9#23454#38469#26041#37327
              ''
              ' '#36710#20027#34920#65306
              '      queueid //'#36710'id'
              '      Taskid   //'#20219#21153'id'
              '      taskname //'#20219#21153#21517#31216
              '      CarNumber //'#36710#21495
              '      Driver    //'#21496#26426
              '      ToneName //'#37197#21512#27604
              '      UseArea  //'#24037#31243#37096#20301
              '      Operator   //'#25805#20316#21592
              '      conAddress //'#27700#27877#20135#22320
              ''
              '      Cube'#9'NUMERIC(8,2)'#9#35745#21010#26041#37327
              '      ActualCube'#9'NUMERIC(8,2)'#9#23436#25104#26041#37327
              '      CardIdx //'#20219#21153#36710#27425#39034#24207
              '      TrayCube'#9'NUMERIC(5,3)'#9#27599#30424#26041#37327
              '      TrayCount'#9'INT'#9#35745#21010#25968
              '      TrayIdx'#9'INT'#9#23436#25104#30424#25968
              '      Btime'#9'DATETIME'#9#24320#22987#26102#38388
              '      Etime'#9'DATETIME'#9#23436#25104#26102#38388
              ''
              #36710#26126#32454#65306
              '  QueueKid'#9'VARCHAR(50)'#9'Key, '#27966#36710#21333'kid'#65292'Mix_ProductionQueue.kid'
              '  Material'#9'VARCHAR(50)'#9'Key,'#26448#26009#21517#31216
              '  Design'#9'NUMERIC(18,4)'#9#35774#23450#20540
              '  Actual'#9'NUMERIC(18,4)'#9#23454#38469#20540
              ''
              #30424#20027#34920#65306
              '  TrayID'#9'VARCHAR(50)'#9#30424'ID'
              '  TaskID'#9'VARCHAR(50)'#9#20219#21153'ID'#65292#23545#24212'Mix_Task.TaskID'
              '  QueueKid'#9'VARCHAR(50)'#9#38431#21015#20027#38190'Kid'
              '  CardIdx'#9'INT'#9#20219#21153#36710#27425#65292#27599#20010#20219#21153#20174#65297#24320#22987#12290
              '  CardTrayIdx'#9'INT'#9#27599#36710#30424#27425#65292#27599#36710#20174#65297#24320#22987#12290
              '  CarNumber'#9'VARCHAR(30)'#9#36710#21495
              '  Cube'#9'DECIMAL(8,3)'#9#30424#26041#37327
              '  TrayIdx'#9'INT'#9#30424#27425#65292#27599#20010#20219#21153#20174#65297#24320#22987#12290
              '  BTime'#9'DATETIME'#9#24320#22987#26102#38388
              '  ETime'#9'DATETIME'#9#32467#26463#26102#38388
              '  Time '#25605#25292#26102#38271
              ''
              #65288#30424#27425#26377#20004#31181#65292#36710#30340#21644#20219#21153#30340'CarTrayIdx'#12289'TrayIdx'#65292#36710#27425':CardIdx'#65289
              #30424#26126#32454#65306
              'TrayID'#9'  VARCHAR(50)'#9#30424'ID'#65292#23545#24212'Mix_Tray. TrayID'
              'Material'#9'VARCHAR(50)'#9#21407#26448#26009#21517#31216
              'Design'#9'  DECIMAL(10,4)'#9#21547#27700#35774#23450#20540'(kg)'
              'Actual'#9'  DECIMAL(10,4)'#9#23436#25104#20540'(kg)'
              'ServTime'#9'DATETIME'#9#26381#21153#22120#26102#38388
              ''
              '')
            TabOrder = 0
            Height = 270
            Width = 826
          end
        end
      end
    end
  end
  object Panel3: TPanel
    Left = 0
    Top = 378
    Width = 838
    Height = 41
    Align = alBottom
    TabOrder = 2
  end
end
